<template>
    <view>
        <!-- parse <include src="../component/navigationBar.wxml"></include> -->
        <block>
            <view class="navigationBox" :style="'padding-top:' + nTop + 'px;height:' + nHeight + 'px;line-height:' + nHeight + 'px;--color:' + color + ';'">
                <view class="nBar" :style="'height:' + nHeight + 'px;top:' + nTop + 'px'">
                    <navigator class="ico" hoverClass="none" :openType="pages.length == 1 ? 'switchTab' : 'navigateBack'" :url="pages.length == 1 ? '/pages/index/index4' : ''">
                        {{ pages.length == 1 ? '' : '' }}
                    </navigator>
                    <view class="title">{{ nTitle }}</view>
                </view>
            </view>
        </block>
        <sjs module="WXS" src="../../res/www.a9a.cn.wxs"></sjs>
        <scroll-view
            @refresherrefresh="onPullDownRefresh"
            @scroll="binnd_scroll"
            @scrolltolower="onReachBottom"
            class="GIFT"
            :enableBackToTop="true"
            :enableFlex="true"
            lowerThreshold="300"
            :refresherEnabled="true"
            :refresherTriggered="triggered"
            :scrollTop="scrolltopNum_index"
            :scrollWithAnimation="true"
            :scrollY="true"
            :style="'margin-top:' + nTH + 'px;height:-webkit-calc(100vh - ' + nTH + 'px);--color:' + color + ';--rgbcolor:' + rgbcolor + ';'"
        >
            <view class="topbg">
                <image mode="widthFix" src="/static/res/img/giftbg.png"></image>
            </view>
            <view class="giflist" v-if="LIST.length > 0" v-for="(dl, index) in LIST" :key="index">
                <view class="li" v-for="(itemli, index1) in dl" :key="index1">
                    <view @tap.stop.prevent="giftwinFn" :data-id="itemli.id">
                        <image mode="aspectFill" :src="itemli.picurl"></image>
                        <view class="h4">{{ itemli.title }}</view>
                        <view class="h5">
                            <text class="i ico"></text>
                            {{ itemli.price }}
                        </view>
                    </view>
                </view>

                <view class="blank">　　　</view>
            </view>
            <view class="nodata" v-if="form_nodata && LIST.length == 0">
                <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
                暂无内容　
                <text @tap="nodatabackFn" data-sokind="default" :style="'color:' + color">返回</text>
            </view>
            <view class="loading" v-if="loading_flag">
                <image class="loading_ico" src="/static/res/img/loading_ico.svg" v-if="loading_ico_flag"></image>
                <text>{{ loading_str }}</text>
            </view>
        </scroll-view>
        <!-- parse <include src="../component/div_gift_btm.wxml"></include> -->
        <block>
            <view @tap="div_gift_btm_closeFn" :class="'mask1 ' + mask_class" v-if="div_gift_btm">
                <view
                    @tap.stop.prevent="emptyFn"
                    :class="'div_bottom div_bottom_yuan ' + div_gift_btm_box_class"
                    :style="'--div_box_height:777rpx;--color:' + color + ';--rgbcolor:' + rgbcolor"
                >
                    <view @tap.stop.prevent="div_gift_btm_closeFn" class="closert ico"></view>
                    <view class="div_gift_btm">
                        <view @tap.stop.prevent="gifrandFn" class="btn4 ico">换一组 </view>
                        <view class="tips">
                            缘分，从送第一份礼物开始认识！
                            <text @tap.stop.prevent="giftmoreFn" class="more ico">更多礼物</text>
                        </view>
                        <view class="giflist">
                            <view class="li" v-for="(itemli, index) in GIFT.LIST" :key="index">
                                <view @tap.stop.prevent="giftwinFn" :data-id="itemli.id">
                                    <image mode="aspectFill" :src="itemli.picurl"></image>
                                    <view class="h4">{{ itemli.title }}</view>
                                    <view class="h5">
                                        <text class="i ico"></text>
                                        {{ itemli.price }}
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
            <view class="mask2 alpha0_100" v-if="div_gift_win">
                <view class="div_box div_gift_win big_normal" style="--div_box_width: 560rpx; --div_box_height: 560rpx">
                    <view @tap="kefu_closeFn" class="close ico"></view>
                    <view class="div_title">送礼物给【{{ U.nickname }}】</view>
                    <view class="div_gift_win_box">
                        <view class="em">
                            <image class="loop_s_b_s" mode="aspectFill" :src="GIFTONE.picurl"></image>
                            <view class="h3">{{ GIFTONE.title }}</view>
                            <view class="h6">{{ GIFTONE.price }}{{ GIFT.dw }}</view>
                        </view>
                        <view @tap="kefu_closeFn" class="a">我再想想</view>
                        <view @tap="gift_sendFn" class="a">立即赠送</view>
                    </view>
                </view>
            </view>
            <view class="tips0_100_0 alpha0_100_0" v-if="tips0_100_0">
                <view class="i ico hi"></view>
                礼物已送出
            </view>
            <view @tap="mask_closeFn" :class="'mask3 ' + mask_class" data-maskid="div_noloveb" v-if="div_noloveb">
                <view
                    @tap.stop.prevent="emptyFn"
                    class="div_box div_data small_big"
                    :style="'--div_box_width:600rpx;--div_box_height:580rpx;--color:' + color + ';--rgbcolor:' + rgbcolor"
                >
                    <view @tap.stop.prevent="mask_closeFn" class="closebtm ico" data-maskid="div_noloveb"></view>
                    <view class="h1">{{ div_data_title }}</view>
                    <rich-text class="C S15" :nodes="div_data_content" style="margin-top: 40rpx"></rich-text>
                    <view class="C S15" style="margin-top: 40rpx">请点击下方按钮购买</view>
                    <view class="C S15">购买后请重新发起送礼</view>
                    <view class="ico picico"></view>
                    <view class="btn_btm cols2">
                        <navigator class="btn4 ico" url="/myPages/loveb/loveb?currentTab=2">在线支付</navigator>
                        <navigator class="btn4 ico" url="/myPages/hongniang/hongniang">找经纪人购买</navigator>
                    </view>
                </view>
            </view>
        </block>
        <view @tap="backtopFn" class="backtop fadeInUp" data-id="index" :style="'color:' + color" v-if="backtop_flag">
            <text class="ico icon-backtop"></text>
            顶部
        </view>
    </view>
</template>

<script>
var t;
var a = require('../../@babel/runtime/helpers/defineProperty');
var i = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
    data() {
        return {
            uid: 0,
            nTitle: '',
            triggered: true,
            loading_flag: false,
            loading_ico_flag: false,
            loading_str: '玩命加载中',
            color: '',
            rgbcolor: '',
            LIST: [],
            form_nodata: false,
            t: 0,
            div_gift_win: false,

            GIFTONE: {
                picurl: '',
                title: '',
                price: ''
            },

            tips0_100_0: false,
            mask_class: '',
            backtop_flag: false,
            nTop: '',
            nHeight: '',
            pages: [],
            scrolltopNum_index: 0,
            nTH: '',
            dl: [],
            div_gift_btm: '',
            div_gift_btm_box_class: '',

            GIFT: {
                LIST: [],
                dw: ''
            },

            U: {
                nickname: ''
            },

            div_noloveb: '',
            div_data_title: '',
            div_data_content: ''
        };
    },
    onLoad: function (t) {
        var a = t.uid;
        var that = this;
        app.globalData.get_config('_ZEAI').then(function (t) {
            that.setData({
                color: app.globalData._ZEAI.color,
                rgbcolor: i.c16_rgb(app.globalData._ZEAI.color)
            });
            uni.setNavigationBarColor({
                backgroundColor: app.globalData._ZEAI.color,
                frontColor: '#ffffff'
            });
            uni.setBackgroundColor({
                backgroundColorTop: app.globalData._ZEAI.color
            });
        });
        app.globalData.get_navigationBarTopHeight(that);
        if (i.ifint(a)) {
            this.setData({
                uid: a
            });
            app.globalData.get_openid().then(function (t) {
                that.init();
            });
        } else {
            uni.showModal({
                content: '用户ID参数错误',
                confirmColor: that.color,
                confirmText: '朕知道了',
                showCancel: false,
                success: function (t) {}
            });
        }
    },
  onReachBottom: function () {},

  onPullDownRefresh: function () {
        var that = this;
        uni.vibrateShort({
            type: 'heavy'
        });
        setTimeout(function () {
            that.setData({
                triggered: false,
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                form_nodata: false,
                t: 0
            });
            that.setloading('end', '拼命加载中');
            2;
            that.init();
        }, 500);
    },
    methods: {
        init: function () {
            var that = this;
            uni.showLoading({
                title: '玩命加载中...',
                mask: true
            });
            false;
            t = uni.getStorageSync('COOK_U');
            app.globalData.ajax({
                url: 'u.php',
                data: {
                    submitok: 'ajax_gift_init',
                    openid: t.openid,
                    uid: that.uid
                },
                success: function (t) {
                    var n;
                    if (1 == t.flag) {
                        uni.setNavigationBarTitle({
                            title: t.nTitle
                        }),
                            0 == t.GIFT.LIST.length
                                ? that.setData({
                                      LIST: [],
                                      form_nodata: true,
                                      nTitle: t.nTitle
                                  })
                                : that.setData((a((n = {}), 'LIST[0]', t.GIFT.LIST), a(n, 'GIFT', t.GIFT), a(n, 'U', t.U), a(n, 'nTitle', t.nTitle), n));
                    } else {
                        uni.showToast({
                            title: t.msg,
                            icon: 'none',
                            mask: true
                        });
                    }
                    true;
                    uni.hideLoading();
                }
            });
        },

        giftwinFn: function (t) {
            var a = t.currentTarget.dataset.id;
            this.setData({
                div_gift_win: true,
                GIFTONE: (function (t, a) {
                    for (var i = a.length, n = 0; n < i; n++) {
                        if (a[n].id == t) {
                            return a[n];
                        }
                    }
                })(a, this.LIST[0])
            });
        },

        gift_sendFn: function () {
            var that = this;
            uni.showLoading({
                title: '正在发送',
                mask: true
            });
            app.globalData.ajax({
                url: 'u.php',
                data: {
                    submitok: 'ajax_gift_send',
                    uid: that.uid,
                    openid: t.openid,
                    gid: that.GIFTONE.id
                },
                success: function (t) {
                    uni.hideLoading();
                    if (1 == t.flag) {
                        that.setData({
                            div_gift_win: false,
                            tips0_100_0: true
                        });
                        setTimeout(function () {
                            that.setData({
                                tips0_100_0: false
                            });
                        }, 3100);
                    } else {
                        t.msg;
                        t.this = that;
                        i.sorry(t);
                    }
                }
            });
        },

        kefu_closeFn: function () {
            this.setData({
                div_gift_win: false
            });
        },

        mask_closeFn: function (t) {
            var that = this;
            var n = t.currentTarget.dataset.maskid;
            if ('back' == t.currentTarget.dataset.closekind) {
                this.setData(a({}, n, false));
                1 == this.pages.length
                    ? uni.exitMiniProgram({
                          success: function (t) {}
                      })
                    : uni.navigateBack();
            }
            this.setData({
                mask_class: 'alpha100_0'
            });
            setTimeout(function () {
                var t;
                that.setData((a((t = {}), n, false), a(t, 'mask_class', 'alpha0_100'), t));
            }, 400);
        },

        nodatabackFn: function () {
            this.setData({
                triggered: false,
                loading_flag: false,
                loading_str: '拼命加载中',
                LIST: [],
                form_nodata: false,
                t: 0
            });
            this.init();
        },

        setloading: function (t, a) {
            'start' == t
                ? this.setData({
                      loading_flag: true,
                      loading_ico_flag: true,
                      loading_str: a
                  })
                : this.setData({
                      loading_flag: false,
                      loading_ico_flag: false,
                      loading_str: a
                  });
        },

        binnd_scroll: function (t) {
            t.detail.scrollTop > 100
                ? this.setData({
                      backtop_flag: true
                  })
                : this.setData({
                      backtop_flag: false
                  });
        },

        backtopFn: function (t) {
            var i = 'scrolltopNum_' + t.currentTarget.dataset.id;
            this.setData(a({}, i, 0));
        },

        onPullDownRefresh() {
            console.log('占位：函数 onPullDownRefresh 未声明');
        },


        div_gift_btm_closeFn() {
            console.log('占位：函数 div_gift_btm_closeFn 未声明');
        },

        emptyFn() {
            console.log('占位：函数 emptyFn 未声明');
        },

        gifrandFn() {
            console.log('占位：函数 gifrandFn 未声明');
        },

        giftmoreFn() {
            console.log('占位：函数 giftmoreFn 未声明');
        }
    }
};
</script>
<style>
@import 'giftmore.css';
</style>
